package kr.hyunist.androidcomplete01saeildamil.ch19;

import kr.hyunist.androidcomplete01saeildamil.*;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;

public class LongTimeEx02 extends Activity {
	int mValue;
	TextView mText;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.longtimeex);

		mText = (TextView) findViewById(R.id.longtimetv);
	}

	public void mOnClick(View v) {
		mValue = 0;
		mHandler.sendEmptyMessage(0);
	}

	Handler mHandler = new Handler() {
		public void handleMessage(Message msg) {

			upDate();

		};
	};

	private void upDate() {
		mValue++;

		mText.setText(Integer.toString(mValue));

		try {
			Thread.sleep(50);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

		if (mValue < 100) {
			mHandler.sendEmptyMessage(0);
		}

	}
}
